
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>购物车_华为商城</title>
<link rel="shortcut icon" href="__PUBLIC__/Ico/favicon.ico"/>
<link href="__PUBLIC__/Css/cart.ec.core.css" rel="stylesheet" type="text/css">
<link href="__PUBLIC__/Css/cart.main.css"  rel="stylesheet" type="text/css">

<js  href="__JQUERY__"/>
</head>
<body>
<!-- 捷径栏 -->
<include file="Public/pinkheader" />
<!--头部 -->
<div class="order-header">
	<div class="g">
    	<div class="fl">
            <div class="logo"><a href=""><img src="__PUBLIC__/images/newLogo.png" /></a></div>
        </div>
        <div class="fr">
            <!--步骤条-三步骤 -->
            <div class="progress-area progress-area-3">
                <!--我的购物车 -->
                <div id="progress-cart" class="progress-sc-area hide" style="display:block;">我的购物车</div>
                <!--核对订单 -->
                <div id="progress-confirm" class="progress-co-area hide" >填写核对订单信息</div>
                <!--成功提交订单 -->
                <div id="progress-submit" class="progress-sso-area hide">成功提交订单</div>
            </div>
        </div>
    </div>
</div>
<div class="layout">
    <!-- 20131223-购物车-start -->
    <div class="sc-list">
    	<!-- 20131223-购物车-商品列表-start -->
		    	<div class="sc-pro-list">
            <!-- 20131223-订单-商品-标题-start -->
            <div class="sc-pro-title-area">
                <div class="h">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                                <th class="tr-check">
                                	
                                </th>
                                <th class="tr-pro">商品</th>
                                <th class="tr-price">单价<em>（元）</em></th>
                                <th class="tr-quantity">数量</th>
                                <th class="tr-subtotal">小计<em>（元）</em></th>
                                <th class="tr-operate">操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <!-- 20131223-订单-商品-标题-end -->

		<form id="cart-form" autocomplete="off" onsubmit="return false;" >
			
			<span id="cart-list"><!--product-list start-->
			  
				<div class="sc-pro-area selected" id="order-pro-1989">
					<table border="0" cellpadding="0" cellspacing="0">
						
						   <!--------------------这是一个商品的信息-------------------------------->
							
						 <!--------------------这是一个商品的信息-------------------------------->
					
					</table>
				</div><!--product-list end-->
				
<script type="text/javascript">
  //ajax的形式获取购物车中的数据
  $(function(){
     
	 
	 
	  doCar();
	 function doCar(){
	   
	     var url="{:U('Cart/error')}";
	     $.ajax({
		     url:"{:U('Cart/cartContent')}",
			 type:'GET',
			 dataType:'json',
			 success:function(responseText,status,xhr){
			     if(status=="success"){
				     if(responseText.cat_status==1){
					     $("#order-pro-1989").find('table').html(responseText.content.str);
						 $("#sc-cartInfo-totalOriginalPrice").find('span').html(responseText.content.car_total_money.toFixed(2));
						 $("#sc-cartInfo-minusPrice").find('span').html(responseText.content.car_sale_money.toFixed(2));
						 $("#sc-cartInfo-totalPrice").find('span').html(responseText.content.car_end_money.toFixed(2));
						 
					 }else{
					   window.location.href=url;
					 }
				 }else{
				    window.location.href=url;
				 }
			 },
			 error:function(){
			    alert('加载失败,请重试');
			 
			 },
			 
			 timeout:60*1000,
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 });
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 }
  
  
  
  
  
  
  
  
  
  
  });


</script>				
<script type="text/javascript">
	  $(function(){
		   //+
		   
		    $("#order-pro-1989").on("click",'.icon-minus-3',function(){
			     var goods_id=$(this).closest('td').parent().find("#box-1989").val();
				
				 
			      var input=$(this).next('input');
				 
				 input.val(function(i,v){
				    
				     return v<=1?1:--v;
				 
				 });
				  var value=input.val();
				  if(value>=0&&value<=10){
				  
				     doAjax(goods_id,value);
				  
				  }
			
			
			
			});
			
			
		    $("#order-pro-1989").on("click",'.icon-plus-3',function(){
			     var goods_id=$(this).closest('td').parent().find("#box-1989").val();
			     var input=$(this).prev('input');
				
				 input.val(function(i,v){
				    
				     return v>9?10:++v;
					 
				 
				 });
				 
				 var value=input.val();
				 if(value>=0&&value<=10){
				      doAjax(goods_id,value);
				 }
			
			
			
			});
			
		 function doAjax(goods_id,num){
		         $.ajax({
				      url:"{:U('Cart/changeGoodsNum')}",
					  type:"POST",
					  data:{
					      'goods_id':goods_id,
						  'goods_num':num
					  },
				      success: function(responseText,status,xhr){
					        if(status=="success"){
							     doCar();
							}else{
							   alert("修改失败");
							}
					  
					  },
					  error:function(){
					      alert("修改失败!");
					  
					  },
					  
					  timeout:60*1000,
					  
				  
				  
				  
				  });
		 
		 
		 
		 
		 }
		   
		 function doCar(){
	   
	     var url="{:U('Cart/error')}";
	     $.ajax({
		     url:"{:U('Cart/cartContent')}",
			 type:'GET',
			 dataType:'json',
			 success:function(responseText,status,xhr){
			     if(status=="success"){
				     if(responseText.cat_status==1){
					     $("#order-pro-1989").find('table').html(responseText.content.str);
						 $("#sc-cartInfo-totalOriginalPrice").find('span').html(responseText.content.car_total_money.toFixed(2));
						 $("#sc-cartInfo-minusPrice").find('span').html(responseText.content.car_sale_money.toFixed(2));
						 $("#sc-cartInfo-totalPrice").find('span').html(responseText.content.car_end_money.toFixed(2));
						 
					 }else{
					   window.location.href=url;
					 }
				 }else{
				    window.location.href=url;
				 }
			 },
			 error:function(){
			    alert('加载失败,请重试');
			 
			 },
			 
			 timeout:60*1000,
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 });
	  }
		    
	  $("#order-pro-1989").on('click','.icon-sc-del',function(){
	         var goods_id=$(this).closest('td').parent().find("#box-1989").val();
			 var url="{:U('Cart/error')}";
			 $.ajax({
			     url:"{:U('Cart/carDel')}",
			     type:"POST",
				 data:{
				      'goods_id':goods_id,
				 },
			     success:function(responseText,status,xhr){
				     if(status=='success'){
					     if(responseText=='1'){
						      var trs=$(this).closest('td').parent().children('tr').size();
						      if(trs<1){
							      doCar();
							  }
						 }else{
						     alert('删失败!');
						 }
					 
					 }else{
					    alert('删失败!');
					 }
				 
				 },
				 
				 error:function(){
				      alert("删除失败");
				 
				 },
				 timeout:60*1000,
			 
			 
			 });
	  
	  
	  
	  
	  
	  });	  
	
      //删除操作按钮点选	
		 $("#checkAll-buttom").click(function(){
		     var delStatus=$(this).prop('checked')?1:0;
			 if(delStatus){
			     $(".checkbox").prop('checked',true);
			 
			 }else{
			     $('.checkbox').prop('checked',false);
			 
			 }
		 
		 });
		
		 $("#cart-all-del").click(function(){
		     
		     var goods_select_ids=$(".checkbox:checked").size();
			 var goods_ids="";
		     if(goods_select_ids>0){
			     $(".checkbox:checked").each(function(i,v){
				     goods_ids+=","+$(this).val();
				  
				 });
			  
			   
			  //ajax执行删除操作
			 var url="{:U('Cart/error')}";
			 $.ajax({
			      url:"{:U('Cart/carDelAll')}",
				  type:"POST",
				  data:{
				      "goods_ids":goods_ids,
				  },
				  success:function(responseText,status,xhr){
				      if(status=="success"){
					     if(responseText==1){
						      doCar();
						     var trs=$("#order-pro-1989").find('table').find('tr').size();
							 if(trs>0){
							    
							 }else{
							     window.location.href=url;
							 }
						 
						 }else{
						 
						      alert("删除失败");
						 }
					  
					  
					  }else{
					     alert("删除失败!");
					  
					  }
				  
				  },
				  error:function(){
				      alert("删除失败!");
				  },
				  timeout:60*1000,
			      
			 
			 
			 });
			 
			 }
			 
			 
		  
		 
		 
		 
		 
		 });
	  
	      
	  
	  
	  });


</script>					  
					
			</span>
		</form>
	</div>
	<div class="hr-20"></div>
		<!--购物车-商品列表 end -->

        <!-- 购物车列表 End-->
    </div>
	<div class="hr-25"></div>
	<div class="sc-total-area clearfix" id="cart-total-area">
		<div class="sc-total-control">
			<input type="checkbox"  autocomplete="off" class="vam" name="" id="checkAll-buttom">
			<label for="checkAll-buttom" class="vam">全选</label>
			<a seed="cart-all-del" href="javascript:void(0);" id="cart-all-del" class="vam" >删除选中商品</a>
		</div>
		<div class="sc-total-price">
			<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
					<tr>
						<th>总计金额：</th>
						<td id="sc-cartInfo-totalOriginalPrice">¥<span>00.00</span></td>
					</tr>
					<tr>
						<th>共节省：</th>
						<td id="sc-cartInfo-minusPrice">¥<span>00.00</span></td>
					</tr>
					<tr>
						<th><em>合计(不含运费)：<em></em></em></th>
						<td><b id="sc-cartInfo-totalPrice">¥<span>00.00</span><b></b></b></td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
	<div class="hr-25"></div>
	<div class="sc-action-area clearfix">
		<a class="button-style-4 button-go-shopping-3" href="{:U('Index/index')}">继续购物</a>
		<a class="button-style-1 button-go-checkout-2" href="{:U('Confirmcart/index')}" seed="cart-pay">去结算</a>
		<div class="sc-action-tips hide" id="sc-action-tips"><div class="tips-style-1 tips-area"><i></i><div class="tips-text"><p id="tips-text-p">购物车中有库存不足商品，请处理后结算</p></div><s></s></div>
		</div>
	</div>
	
    <div class="hr-35"></div>



<!--口号-20121025 -->
<include file="Public/footer" />

</body>
</html>
